import java.util.HashMap;
import java.util.Map;

public class Test {
    private static int duplicate(int[] nums) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int x : nums) {
            if (!map.containsKey(x)) {
                map.put(x, 1);
            } else  {
                return x;
            }
        }
        return -1;
    }


    public static void main(String[] args) {
        int[] arr = {2,3,1,0,2,5,3};
        System.out.println(duplicate(arr));
    }

}
